<%@ Control Language="C#" ClassName="LeftNav" %>

<script runat="server">
  protected bool IsBucketActive(SiteMapNode nodeBucket)
  {
      // pages that don't contain an item in Web.sitemap return null
      return SiteMap.CurrentNode != null && (SiteMap.CurrentNode.Equals(nodeBucket) || SiteMap.CurrentNode.IsDescendantOf(nodeBucket));
  }

</script>

<asp:SiteMapDataSource ID="SiteMapDataSource1" ShowStartingNode="false" runat="server" />
<%--<asp:TreeView ID="TreeView1" DataSourceID="SiteMapDataSource1" runat="server"></asp:TreeView>--%>
<div class="leftNav">
   <asp:Repeater ID="Buckets" runat="server" DataSourceID="SiteMapDataSource1">
     <ItemTemplate>
       <%# IsBucketActive((SiteMapNode)Container.DataItem) ?
           String.Format("<a class=\"selected\" href=\"{0}\">{1}</a><br />",
             ((SiteMapNode)Container.DataItem).Url, 
             ((SiteMapNode)Container.DataItem).Title) :
           String.Format("<a class=\"unselected\" href=\"{0}\">{1}</a><br />", 
             ((SiteMapNode)Container.DataItem).Url,
             ((SiteMapNode)Container.DataItem).Title)
       %>
       
       <asp:Repeater ID="Pails" runat="server" DataSource='<%# ((SiteMapNode)Container.DataItem).ChildNodes %>' 
         Visible='<%# IsBucketActive((SiteMapNode)Container.DataItem)%>'>
         <ItemTemplate>
           <%# String.Format("&nbsp;&nbsp;<a href=\"{0}\">{1}</a><br />", 
               ((SiteMapNode)Container.DataItem).Url, 
               ((SiteMapNode)Container.DataItem).Title) %>
         </ItemTemplate>
       </asp:Repeater>
     </ItemTemplate>
   </asp:Repeater>
</div>